package com.okbihuo.perm.component.file.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.okbihuo.perm.component.file.domain.ComFileReference;
import com.okbihuo.perm.component.file.mapper.ComFileReferenceMapper;
import com.okbihuo.perm.component.file.service.ComFileReferenceService;
import com.okbihuo.perm.core.mp.base.MyServiceImpl;
import com.okbihuo.perm.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;

/**
 * 文件引用接口实现层
 * @author stt
 */
@Service
public class ComFileReferenceServiceImpl extends MyServiceImpl<ComFileReferenceMapper, ComFileReference> implements ComFileReferenceService {

    @Override
    public ComFileReference getByByKeyAndFileId(String key, Long fileId) {
        QueryWrapper<ComFileReference> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtil.humpToUnderline("fileId"),fileId);
        queryWrapper.eq(StringUtil.humpToUnderline("referenceKey"),key);
        return getOne(queryWrapper);
    }

    @Override
    public boolean delByKeyAndFileId(String key, Long fileId) {
        QueryWrapper<ComFileReference> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtil.humpToUnderline("fileId"),fileId);
        queryWrapper.eq(StringUtil.humpToUnderline("referenceKey"),key);
        return remove(queryWrapper);
    }

}
